using System;
using System.Collections.Generic;

namespace Lucene.Linq.Storage
{
    /// <summary>
    /// Entity Storage, Implement this to store an entity on a storage medium not yet implemented
    /// </summary>
    public interface IEntityStorage<T>
        : IEntityStorage
        where T : IEntity
    {
        /// <summary>
        /// Gets an entity from storage
        /// </summary>
        /// <param name="key">Entity key</param>
        /// <returns></returns>
        T Get(string key);

        /// <summary>
        /// Puts an entity in storage
        /// </summary>
        /// <param name="entity">Entity to store</param>
        /// <returns>true if succesfull</returns>
        bool Put(T entity);
    }

    /// <summary>
    /// Non-Generic Entity storage
    /// </summary>
    public interface IEntityStorage
        : IDisposable
    {
        /// <summary>
        /// Puts an object in storage
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        IEntity GetEntity(string key);

        /// <summary>
        /// Puts an object in storage
        /// </summary>
        /// <param name="entity">entity to store</param>
        /// <returns>true if succesfull</returns>
        bool Put(IEntity entity);

        /// <summary>
        /// Checks if the entity exists on the storage medium
        /// </summary>
        /// <param name="key">The Key to use to verify if the entity exists</param>
        /// <returns>True if the entity exists</returns>
        /// <remarks>
        /// This call should not use the index to perform a lookup
        /// </remarks>
        bool Exists(string key);

        /// <summary>
        /// Deletes the entity if it exists on the storage medium
        /// </summary>
        /// <param name="key">The key of the entity to delete</param>
        /// <returns>True if the Key does not, or no longer exists as a stored entity on the storage medium</returns>
        bool Delete(string key);

        /// <summary>
        /// Returns all stored entities
        /// </summary>
        /// <returns></returns>
        IEnumerable<string> All();
    }
}